package com.wujie.hello.spring.cloud.web.admin.ribbon.service;

import com.google.inject.internal.cglib.core.$DefaultNamingPolicy;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author wujie
 * @version 1.0.0:
 * @title AdminService
 * @Description TODO
 * @dateTime 2020/9/4 11:56
 * @Copyright 2020-2021
 */
@Service
public class AdminService {
    @Autowired
    private RestTemplate restTemplate;
    @HystrixCommand(fallbackMethod = "serviceError")
    public String sayHi(String port) {
        return restTemplate.getForObject("http://HELLO-SPRING-CLOUD-SERVER-ADMIN/hi?port=" + port, String.class);
    }

    public String serviceError(String port) {
        return "Hi，this is ribbon.this is port "+ port +" your message is :\"" + port + "\" but request error.";
    }

}
